# /usr/bin/python3
# -*- coding: utf-8 -*-
# @Time    : 2022/1/22 11:33
# @Author  : lt
# @Email   : lt@163.com
# @File    : untils.py
# @Software: PyCharm
import os

from config.setting import DATA_PATH, PATH, CASE_PATH


def set_res(result):

    return result.lower().replace(':','=').replace('"','')

def creat_case():
    dir_list = os.listdir(DATA_PATH)
    for file in dir_list:
        if file.endswith('.yaml') or file.endswith('yml'):
            file = file.split('.')[0]
            tmp_class_name = file.capitalize()
            tmp_case_name = file.lower()
            tmp_yaml_name = file
        template = os.path.join(PATH,'templates')
        with open(template,'r',encoding='utf8') as rf:
            content = rf.read() %{
                'class_name':tmp_class_name,
                'case_name':tmp_case_name,
                'yaml_name':tmp_yaml_name,
            }
        case_file = os.path.join(CASE_PATH,f'test_{tmp_case_name}.py')
        with open(case_file,'w',encoding='utf8') as wf:
            wf.write(content)
